package com.tangula.voicenote.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.tangula.voicenote.R;
import com.tangula.voicenote.entity.ToolsEntity;

import java.util.List;

public class ListViewAdapter extends ArrayAdapter<ToolsEntity> {
    public ListViewAdapter(Context context, int resource,List<ToolsEntity> objects) {
        super(context, resource, objects);
    }


    @NonNull
    @Override
    public View getView(int position, View convertView, @NonNull ViewGroup parent) {
        final ToolsEntity tool = getItem(position);
        @SuppressLint("ViewHolder") View oneToolView = LayoutInflater.from(getContext()).inflate(R.layout.item_list,parent,false);
        TextView toolText = oneToolView.findViewById(R.id.vw_text);
        ImageView toolImage = oneToolView.findViewById(R.id.vw_img);
        assert tool != null;
        toolText.setText(tool.getName());
        toolImage.setImageResource(tool.getImageId());
        return oneToolView;
    }
}
